Component({
    data: {
        active: 0,
        list: [
            {
                icon: 'apps-o',
                text: '工作台',
                url: '/pages/index/index'
            },
            {
                icon: 'comment-o',
                text: '消息',
                url: '/pages/message/message'
            },
            {
                icon: 'user-o',
                text: '我',
                url: '/pages/myCenter/myCenter'
            }
        ]
    },
    methods: {
        onChange(e: { detail: number }) {
            // @ts-ignore
            this.setData({ active: e.detail });
            wx.switchTab({
                // @ts-ignore
                url: this.data.list[e.detail].url
            });
        },
        init() {
            const page = getCurrentPages().pop();
            // @ts-ignore
            this.setData({
                // @ts-ignore
                active: this.data.list.findIndex((item: { url: string; }) => item.url === `/${page.route}`)
            });
        }
    }
});
